<!DOCTYPE HTML>
<html>

<head>
    <meta name="renderer" content="webkit">
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>恒达汽修有限公司</title>

    <link rel="stylesheet" type="text/css" href="css/meteinfo_ui.css" id="metuimodule" data-module="1"/>
    <link rel="stylesheet" type="text/css" href="css/metinfo.css"/>
    <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
    <script src="js/metinfo_ui.js" type="text/javascript"></script>
    <script src="js/ch.js" type="text/javascript"></script>

    <!--[if IE]>
    <script src="public/js/html5.js" type="text/javascript"></script>
    <![endif]-->
    <style>
        BODY {
            SCROLLBAR-FACE-COLOR: #FFFFFF;
            SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF;
            SCROLLBAR-SHADOW-COLOR: #669900;
            SCROLLBAR-3DLIGHT-COLOR: #33FF00;
            SCROLLBAR-ARROW-COLOR: #66CC00;
            SCROLLBAR-TRACK-COLOR: #FFFFFF;
            SCROLLBAR-DARKSHADOW-COLOR: #336600;

            overflow-x: hidden;

            overflow-y: auto;

        }
    </style>
</head>
<body>

<div class=' b-r' style="margin-top: -100px;">
    <div class="clear"></div>
    <div class="active" id="messagelist">
        <h3 class="ctitle">留言内容</h3>

        <dl class='list-none metlist'>
            <dt class='title'><span class='tt'>1<sup>#</sup></span><span class='name'>李先生</span><span class='time'> 2013-03-21 15:37:38</span>
            </dt>
            <dd class='info'><span class='tt'>留言内容</span><span class='text'>你好，我对你们的产品感兴趣……</span></dd>

        </dl>

        <!--<div id="flip">
            <div class='digg4 metpager_8'><span class='disabled disabledfy'><b>«</b></span><span class='disabled disabledfy'>‹</span><span class='current'>1</span><span class='disabled disabledfy'>›</span><span class='disabled disabledfy'><b>»</b></span></div>
        </div>-->
    </div>
</div>

</body>
<script type="text/javascript" src="assets/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
    $.ajax({
        url:"http://localhost:8080/queryAllMessage",
        type:"POST",
        success:function(data){
            console.log(data);
            var resultStr = "";
            if(data.list.length>=1){
                var str ="";
                for(var i = 0;i<data.list.length;i++){
                    var name = data.list[i].name;
                    var phone =  data.list[i].phone;

                    //  循环得到留言信息
                    var appends = data.list[i].messageappends;
                    var replies = data.list[i].messagereplies;

                    console.log(appends);
                    console.log(replies);

                    var appendIndex = 0;
                    var replyIndex = 0;

                    console.log(new Date(appends[appendIndex].messagetime).getTime())
                    console.log(new Date(replies[replyIndex].messagereplytime).getTime())

                    for(;appends[appendIndex].messagetime!=null && replies[replyIndex].messagereplytime!= null;){
                        appendIndex ++;
                        replyIndex++;
                        console.log(replyIndex);
                    }

                    str =str + "<dl class='list-none metlist'><dt class='title'>" +
                        "<span class='tt'>1<sup>#</sup></span>" +
                        "<span class='name'>"+data.list[i].name+"</span>" +
                        "<span class='time'> 2013-03-21 15:37:38</span>" +
                        "</dt>" +
                        "<dd class='info'><span class='tt'>留言内容</span>" +
                        "<span class='text'>你好，我对你们的产品感兴趣……</span></dd>" +
                        "</dl>"
                }
                resultStr = str;
            }else{
                resultStr = "<dl class='list-none metlist'><dt class='title'>没有留言哦</dt></dl>"
            }
            $("div[id=messagelist]").append(resultStr);
        }
    });
</script>
</html>